package sdau.hjk.service.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sdau.hjk.dao.IMajorDao;
import sdau.hjk.entity.Major;
import sdau.hjk.service.IMajorService;

import java.util.ArrayList;
import java.util.List;

/**
 *@version 1.0
 *@author: huangjiakai
 *@create:2021−04-22 15:27
 *@className:sdau.hjk.service.Impl.MajorService
 *@description: TODO
 */
@Service("majorService")
public class MajorService implements IMajorService {
    @Autowired
    private IMajorDao majorDao;

    @Override
    public List<Major> findAll() {
        return majorDao.findAll();
    }

    @Override
    public List<String> findMajor() {
        List<String> major = new ArrayList<String>();
        for(int i = 0; i< majorDao.findMajor().size(); i++){
            major.add(majorDao.findMajor().get(i).getMajor());
        }
        return major;
    }

    @Override
    public List<String> findGrade() {
        List<String> grade = new ArrayList<String>();
        for(int i = 0; i< majorDao.findGrade().size(); i++){
            grade.add(majorDao.findGrade().get(i).getGrade());
        }
        return grade;
    }

    @Override
    public void saveMajor(Major major) {
        majorDao.saveMajor(major);
    }

    @Override
    public void deleteMajor(Major major) {
        majorDao.deleteMajor(major);
    }
}
